#include <iostream>
#include <pthread.h>
#include <sys/types.h>
#include <unistd.h>
using namespace std;
// void *threadRun(void *args)
// {
//     while (1)
//     {
//         std::cout << "other thrad: " <<getpid()<<std::endl;
//         sleep(1);
//     }
// }
// int main()
// {
//     pthread_t tid;

//     pthread_create(&tid, nullptr, threadRun, nullptr);

//     while (1)
//     {
//         std::cout << "main thread: " << getpid() << std::endl;
//         sleep(1);
//     }
// }
class Request
{
public:
    Request(int start,int end):_start(start),_end(end)
    {};
public:
    int _start;
    int _end;

};

class Response
{
public:
    Response(int value,int exitCode):_value(value),_exitCode(exitCode)
    {}
public:
    int _value;
    int _exitCode;

};

void* CountNumber(void* value)
{
    Request* rq=static_cast<Request*>(value);
    Response* rp=new Response(0,0);
    for(int i=rq->_start;i<=rq->_end;i++)
    {
        rp->_value+=i;
    }

    return rp;


}

int main()
{
    pthread_t temp;
    Request* rq=new Request(1,100);
    pthread_create(&temp,nullptr,&CountNumber,rq);

    void* ret;
    pthread_join(temp,&ret);
    Response* rp=static_cast<Response*>(ret);
    cout<<"value= "<<rp->_value<<"exitcode= "<<rp->_exitCode<<endl; 


}
